package date01;

import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        //定义两个数，两个数交换
        //方法一
        int num01=10010;
        System.out.println(num01);
        int num02=10086;
        System.out.println(num02);
        int num03=0;
        num03=num01;
        num01=num02;
        num02=num03;
        System.out.println(num01);
        System.out.println(num02);



        //方法2 难度加大
        /*
        System.out.println("请输入两个数，两个数会交换位置");
        Scanner scanner=new Scanner(System.in);
         double num1=scanner.nextDouble();
         double num2=scanner.nextDouble();
         double num3=0;
         num3=num1;
         num1=num2;
         num2=num3;
         System.out.println(num1);
         System.out.println(num2);

         */


         //方法3  难度再次升级
        //在输入的5个数中 找到最大和最小的两个数并且输出
        System.out.println("请输入5个数");
        Scanner scanner=new Scanner(System.in);
        double num005=scanner.nextDouble();
        double num004=scanner.nextDouble();
        double num003=scanner.nextDouble();
        double num002=scanner.nextDouble();
        double num001=scanner.nextDouble();
        double num[]={num001,num002,num003,num004,num005};
        double maxNum=num001,minNum=num001,maxNum1,minNum1;
        for (int i=1;i<num.length;i++){
            if (num[i-1]<num[i]){
                minNum1=num[i-1];
                maxNum1=num[i];
            }else{
                maxNum1=num[i-1];
                minNum1=num[i];
            }
           if (maxNum<maxNum1){
               maxNum=maxNum1;
           }else if(minNum>minNum1){
               minNum=minNum1;
           }
        }

        System.out.println("最大数是"+maxNum);
        System.out.println("最小数是"+minNum);


    }
}
